package xju_5_6.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect  // 指定切面
@Component  // 指定bean
@Order(2) // 值越小 优先级越高
public class AnnoAdviceOne {
    // 切点
    @Pointcut("execution(* xju_5_6.service.impl.UserServiceImpl.*(..))")
    public void pointCut() {

    }

    // 前置
    @Before("pointCut()")
    public void before() {
        System.out.println("before11");
    }

    // 后置
    @After("pointCut()")
    public void after() {
        System.out.println("after11");
    }
    // 返回
    @AfterReturning("pointCut()")
    public void afterReturning() {
        System.out.println("afterReturning11");
    }
    // 环绕
    @Around("pointCut()")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around 环绕通知之前部分11");
        joinPoint.proceed();
        System.out.println("around 环绕通知之后部分11");
    }
    // 异常
    @AfterThrowing("pointCut()")
    public void afterThrowing() {
        System.out.println("afterThrowing11");
    }
}
